/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ru.rantipin.persistence;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author rantipin
 */
@Entity
@Table(name = "sample")
@NamedQueries({@NamedQuery(name = "Sample.findAll", query = "SELECT s FROM Sample s"), @NamedQuery(name = "Sample.findById", query = "SELECT s FROM Sample s WHERE s.id = :id"), @NamedQuery(name = "Sample.findByName", query = "SELECT s FROM Sample s WHERE s.name = :name"), @NamedQuery(name = "Sample.findByMass", query = "SELECT s FROM Sample s WHERE s.mass = :mass")})
public class Sample implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Column(name = "name")
    private String name;
    @Column(name = "mass")
    private Double mass;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idSample", fetch = FetchType.LAZY)
    private Collection<Scratch> scratchCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idSample", fetch = FetchType.LAZY)
    private Collection<Photo> photoCollection;
    @JoinColumn(name = "id_production", referencedColumnName = "id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Production idProduction;

    public Sample() {
    }

    public Sample(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Double getMass() {
        return mass;
    }

    public void setMass(Double mass) {
        this.mass = mass;
    }

    public Collection<Scratch> getScratchCollection() {
        return scratchCollection;
    }

    public void setScratchCollection(Collection<Scratch> scratchCollection) {
        this.scratchCollection = scratchCollection;
    }

    public Collection<Photo> getPhotoCollection() {
        return photoCollection;
    }

    public void setPhotoCollection(Collection<Photo> photoCollection) {
        this.photoCollection = photoCollection;
    }

    public Production getIdProduction() {
        return idProduction;
    }

    public void setIdProduction(Production idProduction) {
        this.idProduction = idProduction;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Sample)) {
            return false;
        }
        Sample other = (Sample) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ru.rantipin.persistence.Sample[id=" + id + "]";
    }

}
